package com.shi.Dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.shi.entity.GuideMessage;
import com.shi.util.DBHelp;
import com.shi.util.RowMapper;

public class GuideDao {
	private DBHelp<GuideMessage> db = new DBHelp<GuideMessage>();
	public GuideMessage findByName(String name) {
		String sql = "select id,guide,guideNum from t_guidemessage where guide = ?";
		GuideMessage guidemessage = db.executeSelect(sql, new GuideRowMapper(),name); 
		return guidemessage;
	}
	public void save(GuideMessage guidemessage) {
		String sql = "insert into t_guidemessage(id,guide,guideNum) values(?,?,?)";
		db.excuteSQL(sql, guidemessage.getId(),guidemessage.getGuide(),guidemessage.getGuideNum());
	}
	class GuideRowMapper implements RowMapper<GuideMessage>{
		public GuideMessage mapperRow(ResultSet rs) throws SQLException {
			GuideMessage guidemessage = new GuideMessage();
			guidemessage.setId(rs.getString("id"));
			guidemessage.setGuide(rs.getString("guide"));
			guidemessage.setGuideNum(rs.getString("guideNum"));
			return guidemessage;
		}
	}
}
